home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 3 PutContentsIn Igor Pro Folder / Technical Notes / Igor Tech Notes / TN021 Ternary Graphs / Ternary Folder / procedure < prev    next >
Text File  |  1990-10-04  |  4KB  |  143 lines

  1.  
  2. |••••••
  3. |    The GrafTernData() macro converts normalized data waves provided by you 
  4. |        the user into the proper format for plotting on a new ternary or to be 
  5. |        appended to an appropriate target ternary. 
  6. |
  7. |    The following information is specified through a missing parameter dialog: 
  8. |            (1)   Names of the three waves to be graphed.  Only the B and C 
  9. |                   component waves are required for the coordinate transform. 
  10. |                   The wave names supply the axis label names.
  11. |            (2)   One of the three types of ternaries to be displayed.  This is 
  12. |                   optional if appending to a ternary graph.
  13. |            (3)   Names for the X and Y waves that will contain the transformed
  14. |                   data for graphing on the ternary.
  15. |            (4)   Create a new ternary or append to an existing one.
  16. |
  17. |    The new X and Y waves that are created will automatically overwrite any waves  
  18. |        that already have the same name(s).
  19.  
  20. Macro    GrafTernData( Awave, Bwave, Cwave, type, Xwave, Ywave, doNew )
  21.     String        Awave
  22.     Prompt    Awave, "Select the A component wave :", popup, WaveList("*",";","")
  23.     String        Bwave
  24.     Prompt    Bwave, "Select the B component wave :", popup, WaveList("*",";","")
  25.     String        Cwave
  26.     Prompt    Cwave, "Select the C component wave :", popup, WaveList("*",";","")
  27.     Variable    type
  28.     Prompt type, "Ternary graph type :", popup, "Ternary;Ticked Tern;Gridded Tern"
  29.     String        Xwave = "x_Twave"
  30.     Prompt    Xwave, "Name for the ternary X-data wave:"
  31.     String        Ywave = "y_Twave"
  32.     Prompt    Ywave, "Name for the ternary Y-data wave:"
  33.     Variable    doNew
  34.     Prompt    doNew, "What to Do?", popup, "New Ternary;Append"
  35.     
  36.     PauseUpdate; Silent 1
  37.     
  38.     Duplicate    /O    $Bwave, $Xwave, $Ywave
  39.  
  40.     $Xwave = 0.5 * ($Cwave) + ($Bwave)            |    Do the coordinate transformation
  41.     
  42.     $Ywave = $Cwave * cos(30*(Pi/180))            |    Degrees to radians
  43.     
  44.     if( doNew == 1 )                |    Create a new graph
  45.         if( type == 1)
  46.             Ternary()                            |    Vanilla Ternary
  47.         endif
  48.     
  49.         if( type == 2)
  50.             TernTicks()                        |    Ternary with tick marks
  51.         endif
  52.     
  53.         if( type == 3)
  54.             TernGrid()                            |    Ternary with a grid
  55.         endif
  56.  
  57.         ReplaceText    /N=Abox    Awave            |  Add proper labels to ternary apices…
  58.         ReplaceText    /N=Bbox    Bwave
  59.         ReplaceText    /N=Cbox    Cwave
  60.     endif
  61.  
  62.     If( char2num(WinName(0,1)) == char2num("") )        |    Is a target graph window open for appending?
  63.         Abort "Open graph required to append data!"
  64.     endif
  65.  
  66.     String Windo=WinName(0,1)
  67.     DoWindow /F $Windo
  68.     
  69.     Append    $Ywave vs $Xwave
  70.     Modify mode($Ywave)=3
  71. EndMacro
  72.  
  73.  
  74. |•••••
  75. |    ConvertF2P2F() is a utility macro to convert the data waves defining the  
  76. |        ternary graphs to a percent basis or back to fractions again to accommodate  
  77. |        the type of data you are graphing on the ternary.
  78.  
  79. Macro ConvertF2P2F() 
  80.     PauseUpdate; Silent 1        | modifying data…
  81.     
  82.     if(Xaxes[1] == 100)                                    |    Convert percents to fractions
  83.         Xaxes = Xaxes/100;     Yaxes = Yaxes/100
  84.         Xgrid = Xgrid/100;     Ygrid = Ygrid/100
  85.         Xticks = Xticks/100;     Yticks = Yticks/100
  86.     else                                                        |    Convert fractions to percents
  87.         Xaxes = Xaxes*100;     Yaxes = Yaxes*100
  88.         Xgrid = Xgrid*100;     Ygrid = Ygrid*100
  89.         Xticks = Xticks*100;     Yticks = Yticks*100
  90.     endif
  91. EndMacro
  92.  
  93.  
  94. Menu "Macros"
  95.     "Graf Tern Data        /0"
  96.     "(-"
  97.     "Convert F2P2F        /1"
  98. End
  99.  
  100.  
  101. Proc    NameWind()
  102.     Variable    Wnum=0
  103.     String        Wbase="Untitled_", Wname
  104.     
  105.     do
  106.         Wname = Wbase + num2istr( Wnum )
  107.         Wnum += 1
  108.     while( WinType( Wname ) )
  109.     DoWindow /C $Wname
  110. endMacro
  111.  
  112. Window Ternary() : Graph
  113.     PauseUpdate; Silent 1        | building window...
  114.     Display /W=(36,59,317,305) Yaxes vs Xaxes
  115.     Modify margin(top)=36,margin(right)=36,width={Plan,1,bottom,left}
  116.     Modify lHair=0.5
  117.     Modify rgb=(0,0,0)
  118.     Modify noLabel=2
  119.     Modify axThick=0
  120.     Tag /N=Abox/F=0/S=3/A=MT/X=0/Y=-2/L=0 Yaxes, 0, "Comp. A"
  121.     Tag /N=Bbox/F=0/S=3/A=MT/X=0/Y=-2/L=0 Yaxes, 1, "Comp. B"
  122.     Tag /N=Cbox/F=0/S=3/A=MB/X=0/Y=0.5/L=0 Yaxes, 2, "Comp. C"
  123.     NameWind()
  124. EndMacro
  125.  
  126. Window TernTicks() : Graph
  127.     PauseUpdate; Silent 1        | building window...
  128.     Ternary()
  129.     Append Yticks vs Xticks
  130.     Modify lHair=0.5
  131.     Modify rgb(Yticks)=(0,0,65535)
  132. EndMacro
  133.  
  134. Window TernGrid() : Graph
  135.     PauseUpdate; Silent 1        | building window...
  136.     Ternary()
  137.     Append Ygrid vs Xgrid
  138.     Modify lSize(Ygrid)=0.5
  139.     Modify lStyle(Ygrid)=1
  140.     Modify lHair=0.5
  141.     Modify rgb(Ygrid)=(32591,65535,32371)
  142. EndMacro
  143.